package com.credit.management.system.generator.dao;

import com.credit.management.system.model.Company;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CompanyMapper {
    @Delete({
        "delete from company",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into company (id, companyname, ",
        "legalpersonname, Legalpersonidcard, ",
        "registeredcapital, companyprofile, ",
        "companyaddress, phone)",
        "values (#{id,jdbcType=INTEGER}, #{companyname,jdbcType=VARCHAR}, ",
        "#{legalpersonname,jdbcType=VARCHAR}, #{legalpersonidcard,jdbcType=VARCHAR}, ",
        "#{registeredcapital,jdbcType=DECIMAL}, #{companyprofile,jdbcType=VARCHAR}, ",
        "#{companyaddress,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR})"
    })
    int insert(Company record);

    int insertSelective(Company record);

    @Select({
        "select",
        "id, companyname, legalpersonname, Legalpersonidcard, registeredcapital, companyprofile, ",
        "companyaddress, phone",
        "from company",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.credit.management.system.generator.dao.CompanyMapper.BaseResultMap")
    Company selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Company record);

    @Update({
        "update company",
        "set companyname = #{companyname,jdbcType=VARCHAR},",
          "legalpersonname = #{legalpersonname,jdbcType=VARCHAR},",
          "Legalpersonidcard = #{legalpersonidcard,jdbcType=VARCHAR},",
          "registeredcapital = #{registeredcapital,jdbcType=DECIMAL},",
          "companyprofile = #{companyprofile,jdbcType=VARCHAR},",
          "companyaddress = #{companyaddress,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Company record);
}